package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldTrainPlanDto;
import com.cleaningcloud.cld.domain.vo.CldTrainPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.service.ICldTrainPlanService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 培训计划Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/trainPlan")
public class CldTrainPlanController extends BaseController
{
    @Autowired
    private ICldTrainPlanService cldTrainPlanService;

    /**
     * 查询培训计划列表
     */
    @RequiresPermissions("cld:trainPlan:list")
    @GetMapping("/list")
    public TableDataInfo list(CldTrainPlanDto cldTrainPlan)
    {
        startPage();
        List<CldTrainPlanVo> list = cldTrainPlanService.selectCldTrainPlanList(cldTrainPlan);
        return getDataTable(list);
    }


    /**
     * 获取培训计划详细信息
     */
    @RequiresPermissions("cld:trainPlan:query")
    @GetMapping(value = "/{trainPlanId}")
    public AjaxResult getInfo(@PathVariable("trainPlanId") Long trainPlanId)
    {
        return success(cldTrainPlanService.selectCldTrainPlanByTrainPlanId(trainPlanId));
    }

    /**
     * 新增培训计划
     */
    @RequiresPermissions("cld:trainPlan:add")
    @Log(title = "培训计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldTrainPlanDto cldTrainPlan)
    {
        return toAjax(cldTrainPlanService.insertCldTrainPlan(cldTrainPlan));
    }

    /**
     * 修改培训计划
     */
    @RequiresPermissions("cld:trainPlan:edit")
    @Log(title = "培训计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldTrainPlanDto cldTrainPlan)
    {
        return toAjax(cldTrainPlanService.updateCldTrainPlan(cldTrainPlan));
    }

    /**
     * 删除培训计划
     */
    @RequiresPermissions("cld:trainPlan:remove")
    @Log(title = "培训计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trainPlanIds}")
    public AjaxResult remove(@PathVariable Long[] trainPlanIds)
    {
        return toAjax(cldTrainPlanService.deleteCldTrainPlanByTrainPlanIds(trainPlanIds));
    }
}
